def bubble_sort(xarr):
    xlen = len(xarr)
    for i in range(xlen - 1):
        for j in range(0, xlen - 1 - i):
            if xarr[j] > xarr[j + 1]:
                xarr[j], xarr[j + 1] = xarr[j + 1], xarr[j]


xarr_tpl =[1, 8, 5, 3, 1]
xarr1 = xarr_tpl.copy()
bubble_sort(xarr1)
print(xarr1)


def compare_sort(xarr):
    xlen = len(xarr)
    for i in range(xlen):
        ceil_idx = xlen - 1 - i
        max = xarr[0]
        max_idx = 0
        for j in range(1, ceil_idx + 1):
            if xarr[j] > max:
                max = xarr[j]
                max_idx = j
        if max_idx != ceil_idx:
            xarr[max_idx], xarr[ceil_idx] = xarr[ceil_idx], xarr[max_idx]

xarr2 = xarr_tpl.copy()
compare_sort(xarr2)
print(xarr2)
